package view;

import model.ScanRead;

/**
 * description: 用户主界面的类
 * author: 时间
 * time: 2022-01-11-13:17
 */
public class MainView extends ViewRun implements Rules{

    /**
     * Description: 实现Rules接口，界面显示
     * Author: 时间
     * Date: 2022/1/11 16:11
     */
    @Override
    public void views(){
        System.out.println("***************************用户主界面***************************");
        System.out.println("** 1-普通教室预约 **\t** 2-智慧教室预约 **\t** 3-阶梯教室预约 **");
        System.out.println("*50~60人,无智能设备*\t*30~40人,有智能设备*\t*80~90人,有智能设备*\n");
        System.out.println("\t4-历史预约查询\t5-我的信息\t6-退出登录");
        System.out.println("***************************************************************");
        System.out.print("请选择：");
        char chr = ScanRead.readMenu();
        switch (chr){
            case '1':
                ordinaryOrder();
                break;
            case '2':
                wisdomOrder();
                break;
            case '3':
                ladderOrder();
                break;
            case '4':
                historyOrder();
                break;
            case '5':
                myInformation();
                break;
            case '6':
                exit();
                break;
        }
    }

    // 普通教室预约操作(将flags置3)
    private void ordinaryOrder(){
        flags = 3;
    }

    // 智慧教室预约(将flags置4)
    private void wisdomOrder(){
        flags = 4;
    }

    // 阶梯教室预约(将flags置5)
    private void ladderOrder(){
        flags = 5;
    }

    // 历史预约(将flag置7)
    private void historyOrder(){
        flags = 7;
    }

    // 展示我的信息(将flags置6)
    private void myInformation(){
        flags = 6;
    }

    // 将flags置0
    @Override
    public void exit() {
        System.out.print("确定退出登录(y/n)：");
        char chr = ScanRead.readSelection();
        if (chr == 'Y'){
            flags = 0;
        }
    }
}
